package com.macro.mall.controller;

import com.github.pagehelper.PageInfo;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dto.e.RpsTalkEntDTO;
import com.macro.mall.dto.o.RpsTalkOutDTO;
import com.macro.mall.service.RpsTalkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/report/talk")
public class RpsTalkController {
    @Autowired
    private RpsTalkService rpsTalkService;

    @RequestMapping("/list")
    public CommonResult list(@RequestBody RpsTalkEntDTO rpsTalkEntDTO){
        PageInfo<RpsTalkOutDTO> list = rpsTalkService.list(rpsTalkEntDTO);
        return CommonResult.success(list);
    }
    @RequestMapping("/modify")
    public CommonResult modify(@RequestBody RpsTalkEntDTO rpsTalkEntDTO){
        int modify = rpsTalkService.modify(rpsTalkEntDTO);
        CommonResult<Object> commonResult = new CommonResult<>();
        if (modify>0){
            commonResult.setCode(200);
            commonResult.setMessage("操作成功！");
        }else {
            commonResult.setCode(500);
            commonResult.setMessage("操作失败！");
        }
        return commonResult;
    }
    @RequestMapping("/setStatus")
    public CommonResult setStatus(@RequestBody RpsTalkEntDTO rpsTalkEntDTO){
        int modify = rpsTalkService.modify(rpsTalkEntDTO);
        CommonResult<Object> commonResult = new CommonResult<>();
        if (modify>0){
            commonResult.setCode(200);
            commonResult.setMessage("操作成功！");
        }else {
            commonResult.setCode(500);
            commonResult.setMessage("操作失败！");
        }
        return commonResult;
    }
}
